package work.io.aio.client;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousChannel;
import java.nio.channels.AsynchronousSocketChannel;

public class Client {


    public static void main(String[] args) throws IOException, InterruptedException {

        AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();

        //发起连接
        channel.connect(new InetSocketAddress("localhost", 8080));

        ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        byteBuffer.put("你好".getBytes());
        byteBuffer.flip();
        channel.write(byteBuffer);

        Thread.sleep(10000);

    }


}
